import { locations } from "../../../gpu/locations";
const PointShadowFrag =/*wgsl*/`
/**
 *灯光投影下的顶点着色器
 * @class
 *  
 */
 struct PointShadow {
   lightPos:vec3<f32>,    
   far:f32,   
  singleLightCameras:array<mat4x4<f32>>    
};
@group(${locations.SingleLightCamera[0]}) @binding(${locations.SingleLightCamera[1]}) var<storage,read> pointLightShadow : PointShadow;
struct Input {
  @location(0) FragPos:vec4<f32>,
};
struct Output {
    @location(0) color:vec4<f32>,
    @builtin(frag_depth) fragDepth:f32,
};
@fragment 
fn main(input:Input) -> Output {
  var output:Output;
  // 得到片源与光源之间的距离
  var lightDistance = length(input.FragPos.xyz - pointLightShadow.lightPos);

  // 通过除以far_plane映射到[0;1]范围
  lightDistance = lightDistance / pointLightShadow.far;
  // lightDistance = lightDistance / pointLightShadow.far_plane;

  output.fragDepth = lightDistance ;
  // output.color = vec4(input.FragPos.xyz,1.0) ;

  return output;
}
`
export { PointShadowFrag }
